package roborally.program.text;

import roborally.program.command.Command;

/**
 * An interface for describing what a pattern must have so it can create an instance of itself starting from a String.
 * These 'patterns' are no String-patterns.
 * They do contain a String-pattern but they also have methods to check whether a String matches the String-pattern,
 * and to create a procedure/object representing the command.
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 1.0
 */
public interface TextCommandPattern {

	/**
	 * Controls if the given word matches the pattern of this command.
	 * 
	 * @param word The word to be controlled.
	 * @note We assume that in case of a nested command, the inner
	 * commands are correct.
	 */
	public abstract boolean matches(String word);
	
	/**
	 * If the given word matches the pattern of this command, a new command will be created according the word.
	 * 
	 * @param word The word of which a command must be created.
	 * @throws IllegalArgumentException
	 * 		When the word is not valid by the method matches, an exception will occur.
	 * 		In the other case, an exception can occur because of the mechanism of matches
	 * 		(see documentation of matches) 
	 */
	public abstract Command create(String word) throws IllegalArgumentException;

}
